home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / ada / adaed-1.11 / adaed-1 / Adaed-1.11.0a / x2hdeps < prev   
Encoding:
Text File  |  1992-02-07  |  2.9 KB  |  113 lines

  1.  
  2. # This script takes a list of target files and tries to create
  3. #  a set of dependency rules reflecting the recursive dependence
  4. #  on .h files.
  5. #
  6. # This utility is in no way general purpose and in fact (together
  7. #  with other utilities - particularly gethdrs) imposes some
  8. #  restrictions on the code.  It is very tailored to the current
  9. #  Ada/Ed system.  There are probably better ways to do this -
  10. #  writing these utilities was expedient.
  11. #
  12. # Without the '-c' option the input should be a list of .o files.
  13. #  With the '-c' option the input should be a list of .c files.
  14. #
  15. # Some rules it uses for finding the dependencies are:
  16. #
  17. #           TO BE FILLED IN
  18. #
  19. #
  20. # Note that by using 'basename', an argument will only pass if
  21. #  it has no directory prefix.  Besides being simpler, this might
  22. #  be less confusing since the .o files should be built in the same
  23. #  directory containing the sources for pathnames in the headers to
  24. #  make sense.
  25. #
  26.  
  27. if [ "$1" = -c ]; then
  28.     ext=.c
  29.     shift
  30. else
  31.     ext=.o
  32. fi
  33. if [ $# -lt  1 ]; then
  34.     echo usage: x2hdeps [-c] filename...
  35.     exit 1
  36. fi
  37.  
  38. # These names should be safe as temporary file names
  39. tmpname=o2hdeps-tn$$
  40. complist=o2hdeps-cl$$
  41. addlist=o2hdeps-al$$
  42. cat </dev/null >$tmpname
  43. cat </dev/null >$complist
  44.  
  45. while [ $# != 0 ]
  46. do
  47.     bname=`basename $1 $ext`
  48.     if [ $1 = $bname$ext ] ; then echo $bname; fi
  49.     shift
  50. done | sort | uniq | while read bname
  51. do
  52.     wrkname=$bname.c
  53.     rcsname=$wrkname,v
  54.     if [ -r $wrkname ]
  55.     then
  56.         echo  -n "$bname$ext : " >>$tmpname
  57.         gethdrs <$wrkname >> $tmpname
  58.     elif [ -r $rcsname -o -r RCS/$rcsname ]
  59.     then
  60.         echo  -n "$bname$ext : " >>$tmpname
  61.         co -q -p $wrkname | gethdrs >> $tmpname
  62.     fi
  63.     echo >> $tmpname
  64. done
  65.  
  66. while [ X ]
  67. do
  68.     if [ ! -s $tmpname ] ; then break; fi;
  69.     cat $tmpname
  70.     awk '/^[^    ]/ {for (i = 3; i <= NF; i++) printf("%s\n", $i); }' $tmpname|\
  71.       sort | uniq | comm -23 - $complist  >$addlist
  72.     if [ ! -s $addlist ] ; then break; fi;
  73.     sort -m $complist $addlist >$tmpname
  74.     mv $tmpname $complist
  75.  
  76.     cat $addlist| while read hfile
  77.     do
  78.         deps=""
  79.         hbase=`basename $hfile .h`
  80.         if [ $hbase.h != $hfile ]; then continue; fi
  81.         if [ -r $hbase.vbs ]; then
  82.             hname=$hbase.vbs
  83.             echo "$hfile : $hname" >>$tmpname
  84.             deps=`gethdrs <$hbase.vbs`
  85.         elif [ -r $hbase.vbs,v -o -r RCS/$hbase.vbs,v ]; then
  86.             hname=$hbase.vbs
  87.             echo "$hfile : $hname" >>$tmpname
  88.             deps=`co -q -p $hbase.vbs | gethdrs`
  89.         elif [ -r $hbase.ch ]; then
  90.             hname=$hbase.ch
  91.             echo "$hfile : $hname" >>$tmpname
  92.             deps=`makech -h <$hbase.ch | gethdrs`
  93.         elif [ -r $hbase.ch,v -o -r RCS/$hbase.ch,v ]; then
  94.             hname=$hbase.ch
  95.             echo "$hfile : $hname" >>$tmpname
  96.             deps=`co -q -p $hbase.ch | makech -h | gethdrs`
  97.         elif [ -r $hfile ]; then
  98.             hname=$hfile
  99.             deps=`gethdrs <$hfile`
  100.         elif [ -r $hfile,v -o -r RCS/$hfile,v ]; then
  101.             hname=$hfile
  102.             deps=`co -q -p $hfile | gethdrs`
  103.         fi
  104.         if [ "$deps" != "" ] 
  105.         then
  106.             echo "$hname : $deps" >>$tmpname
  107.             echo "    [ -f $hname ] && touch $hname" >>$tmpname
  108.         fi
  109.     done
  110. done
  111.  
  112. rm -f $tmpname $complist $addlist
  113.